<?php
    /**
     * User zgh
     * Email 1803897171@qq.com
     * Date 2021/8/5
     **/

    namespace app\api\controller;

    use app\api\service\NewsService;
    use app\common\controller\ApiController;
    use hg\apidoc\annotation as Apidoc;
    use app\common\Annotation\ApiControllerAnnotation;
    use think\facade\Request;


    /**
     * @ApiControllerAnnotation(auth=0)
     * @Apidoc\Title("资讯模块")
     * @Apidoc\Group("base")
     * Class LoginController
     * @package app\api\controller
     */
    class NewsController extends ApiController
    {

        /**
         * @Apidoc\Title("资讯列表")
         * @Apidoc\Url("news/get_list")
         * @Apidoc\Param(ref="app\api\apidoc\NewsDoc\get_list")
         * @Apidoc\Returned(ref="app\api\apidoc\NewsDoc\get_list")
         */
        public function get_list()
        {
            $result_data = NewsService::getList(Request::param());
            return success_json_response($result_data);
        }

        /**
         * @Apidoc\Title("资讯详情")
         * @Apidoc\Url("news/get_detail")
         * @Apidoc\Param(ref="app\api\apidoc\NewsDoc\get_detail")
         * @Apidoc\Returned(ref="app\api\apidoc\NewsDoc\get_detail")
         */
        public function get_detail()
        {
            $result_data = NewsService::getDetail(Request::param());
            return success_json_response($result_data);
        }


        /**
         * @Apidoc\Title("资讯分享")
         * @Apidoc\Url("news/share")
         * @Apidoc\Param(ref="app\api\apidoc\NewsDoc\share")
         * @Apidoc\Returned(ref="app\api\apidoc\NewsDoc\share")
         */
        public function share()
        {
            $res = NewsService::share(Request::param());
            if ($res) {
                return success_json_response("分享成功");
            } else {
                return json_response("分享失败");
            }
        }


    }